/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.kgierlicka.matrix.view;

import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.Properties;
import pl.kgierlicka.matrix.model.MatrixOperation;
import java.util.logging.Level;
import java.util.logging.Logger;
import pl.kgierlicka.matrix.database.MatrixDataBase;
import pl.kgierlicka.matrix.exceptions.WrongMatrixDimensionsException;
import pl.kgierlicka.matrix.model.MatrixModel;


/**
 *
 * @author kgierlicka
 *
 */
public class MatrixMainFrame extends javax.swing.JFrame {

    
    MatrixModel matrix1Model = null;
    MatrixModel matrix2Model = null;
    MatrixModel resultModel = null;
    
    MatrixDataBase mdb = null;
    

    
    /**
     * Creates new form MatrixMainFrame
     */
    public MatrixMainFrame() {
        initComponents();
        
            
    mdb = new MatrixDataBase();
             
    mdb.connect();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        messageDialog = new javax.swing.JDialog();
        messageLabel = new javax.swing.JLabel();
        dialogOKButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        matrix1Table = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        matrix2Table = new javax.swing.JTable();
        rowCount2ComboBox = new javax.swing.JComboBox();
        columnCount2ComboBox = new javax.swing.JComboBox();
        rowCount1ComboBox = new javax.swing.JComboBox();
        columnCount1ComboBox = new javax.swing.JComboBox();
        matrix1CreateButton = new javax.swing.JButton();
        matrix2CreateButton = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        resultTable = new javax.swing.JTable();
        jToolBar1 = new javax.swing.JToolBar();
        addButton = new javax.swing.JButton();
        subtractButton = new javax.swing.JButton();
        multiplyButton1 = new javax.swing.JButton();
        divideButton = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();

        messageDialog.setTitle("Błąd!");
        messageDialog.setAlwaysOnTop(true);
        messageDialog.setBackground(java.awt.Color.white);
        messageDialog.setLocationByPlatform(true);
        messageDialog.setMinimumSize(new java.awt.Dimension(500, 150));
        messageDialog.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
        messageDialog.setResizable(false);
        messageDialog.setType(java.awt.Window.Type.POPUP);

        messageLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        messageLabel.setForeground(new java.awt.Color(204, 0, 0));
        messageLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        messageLabel.setText("jLabel1");

        dialogOKButton.setText("OK");
        dialogOKButton.setFocusPainted(false);
        dialogOKButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dialogOKButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout messageDialogLayout = new javax.swing.GroupLayout(messageDialog.getContentPane());
        messageDialog.getContentPane().setLayout(messageDialogLayout);
        messageDialogLayout.setHorizontalGroup(
            messageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(messageDialogLayout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addComponent(messageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 422, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(36, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, messageDialogLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(dialogOKButton)
                .addGap(220, 220, 220))
        );
        messageDialogLayout.setVerticalGroup(
            messageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(messageDialogLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(messageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(dialogOKButton)
                .addContainerGap(53, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMaximumSize(new java.awt.Dimension(800, 600));
        setPreferredSize(new java.awt.Dimension(800, 600));
        setResizable(false);

        matrix1Table.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        matrix1Table.getTableHeader().setResizingAllowed(false);
        matrix1Table.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(matrix1Table);
        matrix1Table.getAccessibleContext().setAccessibleName("");
        matrix1Table.getAccessibleContext().setAccessibleDescription("");

        jScrollPane2.setViewportView(matrix2Table);

        rowCount2ComboBox.setMaximumRowCount(10);
        rowCount2ComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "" }));
        rowCount2ComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rowCount2ComboBoxActionPerformed(evt);
            }
        });

        columnCount2ComboBox.setMaximumRowCount(10);
        columnCount2ComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "" }));
        columnCount2ComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                columnCount2ComboBoxActionPerformed(evt);
            }
        });

        rowCount1ComboBox.setMaximumRowCount(10);
        rowCount1ComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "50" }));
        rowCount1ComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rowCount1ComboBoxActionPerformed(evt);
            }
        });
        rowCount1ComboBox.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                rowCount1ComboBoxPropertyChange(evt);
            }
        });

        columnCount1ComboBox.setMaximumRowCount(10);
        columnCount1ComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "" }));
        columnCount1ComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                columnCount1ComboBoxActionPerformed(evt);
            }
        });

        matrix1CreateButton.setText("Utwórz");
        matrix1CreateButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                matrix1CreateButtonActionPerformed(evt);
            }
        });

        matrix2CreateButton.setText("Utwórz");
        matrix2CreateButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                matrix2CreateButtonActionPerformed(evt);
            }
        });

        resultTable.setColumnSelectionAllowed(true);
        resultTable.setEnabled(false);
        resultTable.setRequestFocusEnabled(false);
        resultTable.setRowSelectionAllowed(false);
        resultTable.setUpdateSelectionOnSort(false);
        resultTable.setVerifyInputWhenFocusTarget(false);
        jScrollPane3.setViewportView(resultTable);

        jToolBar1.setRollover(true);

        addButton.setText("+");
        addButton.setMaximumSize(new java.awt.Dimension(40, 25));
        addButton.setMinimumSize(new java.awt.Dimension(40, 25));
        addButton.setPreferredSize(new java.awt.Dimension(40, 25));
        addButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(addButton);

        subtractButton.setText("-");
        subtractButton.setMaximumSize(new java.awt.Dimension(40, 25));
        subtractButton.setMinimumSize(new java.awt.Dimension(40, 25));
        subtractButton.setPreferredSize(new java.awt.Dimension(40, 25));
        subtractButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                subtractButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(subtractButton);

        multiplyButton1.setText("*");
        multiplyButton1.setMaximumSize(new java.awt.Dimension(40, 25));
        multiplyButton1.setMinimumSize(new java.awt.Dimension(40, 25));
        multiplyButton1.setPreferredSize(new java.awt.Dimension(40, 25));
        multiplyButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                multiplyButton1ActionPerformed(evt);
            }
        });
        jToolBar1.add(multiplyButton1);

        divideButton.setText("/");
        divideButton.setMaximumSize(new java.awt.Dimension(40, 25));
        divideButton.setMinimumSize(new java.awt.Dimension(40, 25));
        divideButton.setPreferredSize(new java.awt.Dimension(40, 25));
        divideButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                divideButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(divideButton);

        jMenu1.setText("Operacja");

        jMenuItem1.setText("Dodawanie");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Odejmowanie");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuItem3.setText("Mnożenie");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuItem4.setText("Dzielenie");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 783, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 356, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(162, 162, 162)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(98, 98, 98)
                .addComponent(rowCount1ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(columnCount1ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(matrix1CreateButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(rowCount2ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(columnCount2ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(matrix2CreateButton)
                .addGap(177, 177, 177))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rowCount1ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(columnCount1ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(matrix1CreateButton)
                    .addComponent(rowCount2ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(columnCount2ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(matrix2CreateButton))
                .addGap(33, 33, 33)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(45, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void columnCount2ComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_columnCount2ComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_columnCount2ComboBoxActionPerformed

    private void rowCount2ComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rowCount2ComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_rowCount2ComboBoxActionPerformed

    private void rowCount1ComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rowCount1ComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_rowCount1ComboBoxActionPerformed

    private void columnCount1ComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_columnCount1ComboBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_columnCount1ComboBoxActionPerformed

    private void rowCount1ComboBoxPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_rowCount1ComboBoxPropertyChange
        
        
    }//GEN-LAST:event_rowCount1ComboBoxPropertyChange

    private void matrix1CreateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_matrix1CreateButtonActionPerformed
        
        
        matrix1Model = new MatrixModel(Integer.valueOf(rowCount1ComboBox.getSelectedItem().toString()), Integer.valueOf(columnCount1ComboBox.getSelectedItem().toString()));
        
        matrix1Table.setModel(matrix1Model);
       
        
    }//GEN-LAST:event_matrix1CreateButtonActionPerformed

    private void matrix2CreateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_matrix2CreateButtonActionPerformed
 
       matrix2Model = new MatrixModel(Integer.valueOf(rowCount2ComboBox.getSelectedItem().toString()), Integer.valueOf(columnCount2ComboBox.getSelectedItem().toString()));
        
        matrix2Table.setModel(matrix2Model);
        
        // TODO add your handling code here:
    }//GEN-LAST:event_matrix2CreateButtonActionPerformed

    private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
        
        doMatrixOperation(MatrixOperation.MATRIX_ADD);

    }//GEN-LAST:event_addButtonActionPerformed

    private void subtractButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subtractButtonActionPerformed
     
        doMatrixOperation(MatrixOperation.MATRIX_SUBTRACT);

        
    }//GEN-LAST:event_subtractButtonActionPerformed

    private void multiplyButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multiplyButton1ActionPerformed

        doMatrixOperation(MatrixOperation.MATRIX_MULTIPLY);
    }//GEN-LAST:event_multiplyButton1ActionPerformed

    private void divideButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_divideButtonActionPerformed
        
        doMatrixOperation(MatrixOperation.MATRIX_DIVIDE);
    }//GEN-LAST:event_divideButtonActionPerformed

    private void doMatrixOperation( MatrixOperation operation) {
        
       if (matrix1Model != null && matrix2Model != null) { 
        
            try {
        
                switch (operation) {
                    case MATRIX_ADD:
                    resultModel = new MatrixModel(matrix1Model.add(matrix2Model));
                    break;
                    case MATRIX_SUBTRACT:
                    resultModel = new MatrixModel(matrix1Model.subtract(matrix2Model));
                    break;
                    case MATRIX_MULTIPLY:
                    resultModel = new MatrixModel(matrix1Model.multiply(matrix2Model));
                    break;
                    case MATRIX_DIVIDE:
                    resultModel = new MatrixModel(matrix1Model.divide(matrix2Model));
                    break;
                      
                }
                resultTable.setModel(resultModel);

                
                mdb.save(matrix1Model, matrix2Model, resultModel, operation);
                
                

            } catch (WrongMatrixDimensionsException ex) {
                showDialog(ex.getMessage());
            }
     
       }
    }
    
    
    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
     doMatrixOperation(MatrixOperation.MATRIX_ADD);
        
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void dialogOKButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dialogOKButtonActionPerformed
        messageDialog.setVisible(false);
        
        
    }//GEN-LAST:event_dialogOKButtonActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
     doMatrixOperation(MatrixOperation.MATRIX_SUBTRACT);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
     doMatrixOperation(MatrixOperation.MATRIX_MULTIPLY);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
     doMatrixOperation(MatrixOperation.MATRIX_DIVIDE);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    /**
     * Wyświetla komunikat zamieniając go wcześniej na duże litery (za pomocą aplikacji WEB)
     * @param message Komunikat do wyświetlenia
     */
    
    private void showDialog(String message) {
      try {
            URI uri = new URI(
            "http", 
            "localhost:8080", 
            "/ToUpperServlet/ToUpperServlet",
            "text=" + URLEncoder.encode(message, "UTF-8"),
            null);

            URL url = uri.toURL();
            URLConnection connection = url.openConnection();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        
            String upperedText = in.readLine();
           
            messageLabel.setText(upperedText); 
            messageDialog.setVisible(true);
        } catch (Exception ex) {
            Logger.getLogger(MatrixMainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
 
    /**
     * Główna funkcja aplikacji
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MatrixMainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MatrixMainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MatrixMainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MatrixMainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            
            
            public void run() {
                new MatrixMainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addButton;
    private javax.swing.JComboBox columnCount1ComboBox;
    private javax.swing.JComboBox columnCount2ComboBox;
    private javax.swing.JButton dialogOKButton;
    private javax.swing.JButton divideButton;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton matrix1CreateButton;
    private javax.swing.JTable matrix1Table;
    private javax.swing.JButton matrix2CreateButton;
    private javax.swing.JTable matrix2Table;
    private javax.swing.JDialog messageDialog;
    private javax.swing.JLabel messageLabel;
    private javax.swing.JButton multiplyButton1;
    private javax.swing.JTable resultTable;
    private javax.swing.JComboBox rowCount1ComboBox;
    private javax.swing.JComboBox rowCount2ComboBox;
    private javax.swing.JButton subtractButton;
    // End of variables declaration//GEN-END:variables
}
